<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/MasterPage.Master" Inherits="System.Web.Mvc.ViewPage<Animoso.Domain.Sponsor>" %>
<%@ Import Namespace="Animoso.Domain" %>
<%@ Import Namespace="Animoso.Web.Controllers" %>

<asp:Content ID="Head" ContentPlaceHolderID="HeadPlaceHolder" runat="server">
    <link href="../../uploadify/uploadify.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
    $(document).ready(function() {
        $('#upload').uploadify({
            'uploader': '/uploadify/uploadify.swf',
            'cancelImg': '/uploadify/cancel.png',
            'script': '/Sponsor/Upload',
            'onComplete': handleResponse,
            'scriptData': { sponsorId: '<%=Model.Id %>' }
        });
    });

    function handleResponse(vent, queueID, fileObj, response, data) {                
        $('#fotoPreview').attr('src', '/Upload/<%=Folders.SPONSOR_PICTURE_FOLDER %>/' + response.toString());
    }
</script>
</asp:Content>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Create
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>Create</h2>

    <%= Html.ValidationSummary("Create was unsuccessful. Please correct the errors and try again.") %>

    <% using (Html.BeginForm("Edit", "Sponsor", FormMethod.Post))
       {%>

        <fieldset>
            <legend>Fields</legend>
            <p>
                <label for="Name">Name:</label><br />
                <%=Html.TextBox("Name")%>
                <%=Html.ValidationMessage("Name", "*")%>
            </p>
            <p>
                <label for="Link">Link:</label><br />
                <%=Html.TextBox("Link")%>
                <%=Html.ValidationMessage("Link", "*")%>
            </p>
            <p>
                <label for="Picture">Picture:</label><br />
                <input type="file" name="upload" id="upload" />
                <a href="javascript:$('#upload').uploadifyUpload();">Upload</a>
                <%=Html.ValidationMessage("Picture", "*")%>
                <% if (!string.IsNullOrEmpty(Model.Picture))
{%>
                    <img id="fotoPreview" src="/Upload/<%=Folders.SPONSOR_PICTURE_FOLDER + "/" + Model.Picture%>" />
                    <%
}
                   else
                   {
           %>
           <img id="fotoPreview" />
           <% } %>
            </p>            
            <p>
                <label for="ImageLocation">Banner locatie:</label><br />
                <%=Html.DropDownList("ImageLocation", (IEnumerable<SelectListItem>) ViewData["ImageLocationList"]) %>
                <%= Html.ValidationMessage("ImageLocation", "*")%>
            </p>            
            <p>
                <%=Html.Hidden("Id", Model.Id) %>
                <input type="submit" value="Create" />
            </p>
        </fieldset>

    <% } %>

    <div>
        <%=Html.ActionLink("Back to List", "Index") %>
    </div>

</asp:Content>